/********************************************************/
/*	Project:					*/
/*	Author:		gong_libin			*/
/*	Date:		2016_01_01			*/
/*	File:		GlbMongo.h			*/
/********************************************************/

#ifndef	_GLB_MONGO_H
#define	_GLB_MONGO_H

#include "GlbGlobal.h"
#include <mongoc.h>

class CGlbMongo
{
public:
	CGlbMongo();
	virtual ~CGlbMongo();

	void GlbMongoInit();
	void GlbMongoClean();

	void GlbDestroyCursor();
	void GlbDestroyClient();
	void GlbDestroyDatabase();
	void GlbDestroyCollection();

	void GlbDropCollection();
	int GlbGetClient(char* pszUri);
	int GlbGetDatabase(char* pszData);
	int GlbGetCollection(char* pszData, char* pszColl);

	bool GlbCursorMore();
	char* GlbCursorError();
	bson_t* GlbCursorNext();

	void GlbCollClean();
	void GlbCollTraverse();
	bool GlbCollInsert(bson_t* pstDoc);
	bool GlbCollDelete(bson_t* pstDoc);
	bool GlbCollUpdate(bson_t* pstSel, bson_t* pstUpd);
	void GlbCollSelect(bson_t* pstQuery, bson_t* pstField);

protected:
	mongoc_cursor_t* m_pstCur;
	mongoc_client_t* m_pstCli;
	mongoc_database_t* m_pstData;
	mongoc_collection_t* m_pstColl;

private:

};

#endif /* _GLB_MONGO_H */
